<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ui>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="../css/styles.css" />
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="../css/flexigrid.css" />
		<link rel="stylesheet" type="text/css" charset="utf-8"
			href="../css/flexigrid.css" />

		<script type="text/javascript" src="/hrms/js/jquery-1.7.2.min.js"></script>

		<script type="text/javascript" src="/hrms/js/jquery.container.js"></script>

		<script type="text/javascript" src="/hrms/js/common.js"></script>

		<script type="text/javascript" src="/hrms/js/flexigrid.pack.js"></script>

		<script type="text/javascript">
	$(document).ready( function() {
		demand("workplatform");
		//外部查询
		$("#workplatform_query").click(function(){
			var taskname=$("#taskname").val();
			var tasktype=$("#tasktype").val();
			var option = {extParam: [{ name: "taskname", value:taskname },{name:"tasktype",value:tasktype}]};
			$("#querylist").flexOptions(option).flexReload();
		});
	});
</script>

	</head>

	<body onload="loadDemand('workplatform')">
				<div align="center">
				<br />
				<br />
				<br />
					<form id="workplatform" action="/hrms/webservice/resources/task/queryByPage" mothed="get">
					<table width="90%" border="0" class="table_frame" align="center">
						<thead class="table_title">
							<tr>
								<td align="center">
									工作台
								</td>
							</tr>

						</thead>
						<tr>
							<td>
								<table width="100%" border="0" class="table_block">
									<tr>
										<td align="right">
											工作项名称：
										</td>
										<td align="left">
											<input id="taskname" name="taskname" type="text" size="20" />
											&nbsp;
										</td>
										<td align="right">
											工作项类型：
										</td>
										<td align="left">
											<select id="tasktype" name="tasktype" style="width: 20">
												<option value="01">
													取自工作项类型字典
												</option>
											</select>
										</td>
									</tr>
									<tr>
										<td colspan="4" align="center">
											<input id="workplatform_query" name="query" type="button" value="查询" class="button_image" />
											<input name="reset" type="reset" class="button_image" />
										</td>

									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td></td>
						</tr>
						<tr>
							<td>
								<div>
									<table id="querylist"></table>
								</div>
							</td>
						</tr>
					</table>
					<div align="center">
						<br />
						<br />
						<table width="90%" border="0" class="table_frame" align="center">
							<tr>
								<td align="center">
									<input id="demand" name="" type="button" value="需求收集"
										class="button_image" />
								</td>
							</tr>
							<tr>
								<td align="center">
									<div id="demand_input" style="display: none">
										<textarea rows="15" cols="120" id="demand_text"></textarea>
										<br />
										<input id="demand_save" type="button" class="button_image"
											value="保存需求" />
									</div>
								</td>
							</tr>
						</table>
						<table id="demand_des" width="90%" border="0" class="table_frame"
							align="center">
							<thead align="center" class="table_title">
							<tr><td>
									需求描述
								</td></tr>
							</thead>
						</table>
					</div>
					</form>
				</div>
				<script type="text/javascript">
	$("#querylist").flexigrid( {
		url :'/hrms/webservice/resources/task/queryByPage',
		dataType :'json',
		colModel : [ {
			display :'代办任务编号',
			name :'taskcode',
			width :160,
			sortable :true,
			align :'center'
		}, {
			display :'代办任务名称',
			name :'taskname',
			width :180,
			sortable :true,
			align :'left'
		}, {
			display :'代办任务类型',
			name :'tasktype',
			width :120,
			sortable :true,
			align :'left',
			hide:true
		}, {
			display :'代办任务类型',
			name :'typename',
			width :120,
			sortable :true,
			align :'left'
		}, {
			display :'代办任务状态',
			name :'state',
			width :130,
			sortable :true,
			align :'left',
			hide :true
		}, {
			display :'代办任务状态',
			name :'stateStr',
			width :130,
			sortable :true,
			align :'left',
			hide :false
		}, {
			display :'代办任务地址',
			name :'taskurl',
			width :80,
			sortable :true,
			align :'right',
			hide:true
		}, {
			display :'代办任务接收时间',
			name :'accepttimeStr',
			width :80,
			sortable :true,
			align :'right'
		}, {
			display :'代办任务处理时间',
			name :'processtimeStr',
			width :80,
			sortable :true,
			align :'right'
		}, {
			display :'代办任务更新时间',
			name :'updatedateStr',
			width :80,
			sortable :true,
			align :'right'
		} ],
		buttons : [ {
			name :'处理任务',
			bclass :'add',
			onpress :process
		}, {
			name :'任务终止',
			bclass :'delete',
			onpress :process
		}, {
			separator :true
		} ],
		searchitems : [ {
			display :'代办任务名称',
			name :'tasktype'
		}, {
			display :'代办任务状态',
			name :'state',
			isdefault :true
		} ],
		sortname :"annalid",
		sortorder :"asc",
		usepager :true,
		title :'代办任务列表',
		useRp :true,
		rp :15,
		showTableToggleBtn :true,
		width :1000,
		height :200
	});
	function process(com, grid) {

		if (com == '处理任务') {
			var selected_length=$(".trSelected",grid).length;
				if(selected_length<1){
					alert("请选择一条需要处理的任务后，再点击任务处理按钮！");
					return false;
				}
				if(selected_length>1){
					alert("任务处理只能选择一条任务进行处理，请重新选择任务！");
					return false;
				}
			var taskcode=$(".trSelected td:nth-child(1) div",grid).text();
			var state=$(".trSelected td:nth-child(4) div",grid).text();
			var url=$(".trSelected td:nth-child(7) div",grid).text();
			if(state==="1")
			$.ajax({url:"/hrms/webservice/resources/task/process?taskcode="+taskcode,success:function(msg){
					alert("任务接收成功！");
				},error:function(XMLHttpRequest, textStatus, errorThrown){
					alert("任务处理时出现异常！");
				}});
			//转向具体的处理页面
			self.location=url;
		} else if (com == '任务终止') {

			var iscon=confirm('确认该项工作任务终止？');
			if(iscon){
				var selected_length=$(".trSelected",grid).length;
				if(selected_length<1){
					alert("请选择一条需要终止的任务后，再点击任务终止按钮！");
					return false;
				}
				var codes="";
				$(".trSelected td:nth-child(1) div",grid).each(function(index) {
				  if(index){
				  	codes+=",";
				  }
				  codes+=$(this).text();
				});
				$.ajax({url:"/hrms/webservice/resources/task/terminate?taskcodes="+codes,success:function(msg){
					alert("任务终止成功！");
					$("#querylist").flexReload();
				},error:function(XMLHttpRequest, textStatus, errorThrown){
					alert("终止任务时出现异常！");
				}});
			}


		}

	}
</script>
	</body>
</html>
